const fs = require("fs");
const config = require("./project.config.json");

const buildEnv = process.env.BUILD_ENV || "production";
const nodeEnv = process.env.NODE_ENV || "production";

let toastText = "";
switch (buildEnv) {
  case "test":
    config.appid = "wx62d1ef8abd85356b";
    toastText = "修改当前项目为雪后春归体验版";
    break;
  case "develop":
    config.appid = "wx62d1ef8abd85356b";
    toastText = "修改当前项目为雪后春归开发版";
    break;
  case "gray":
    config.appid = "wx32083f8f9ff2c48a";
    toastText = "修改当前项目为微拍联盟体验版";
    break;

  case "production":
    config.appid = "wx32083f8f9ff2c48a";
    toastText = "修改当前项目为微拍联盟线上版";
    break;
  default:
    break;
}

config.BUILD_ENV = buildEnv;
config.NODE_ENV = nodeEnv;
fs.writeFileSync("./project.config.json", JSON.stringify(config, null, "  "));
console.log(
  "🔥🔥🔥",
  toastText,
  `buildEnv:${buildEnv}, nodeEnv:${nodeEnv}`,
  "🔥🔥🔥"
);
